<!DOCTYPE html>












  


<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">






  
  
    
      
    
    
      
    
  <script src="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script>
  <link href="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/blue/pace-theme-flash.min.css" rel="stylesheet">



<script>
    (function () {
        if ('') {
            if (prompt('请输入文章密码') !== '') {
                alert('密码错误！');
                if (history.length === 1) {
                    location.replace("http://xxxxxxx.xxx"); // 这里替换成你的首页
                } else {
                    history.back();
                }
            }
        }
    })();
</script>





<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">



  <meta name="google-site-verification" content="zrNUWIf25v2J4dC1wliso_DUXEwYoECv4j3h9CE34xM">








  <meta name="baidu-site-verification" content="nuHze5uXZ7">







  
  
    
  
  <link href="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet" type="text/css">




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  

  
    
      
    

    
  

  
    
    
    <link href="https://fonts.cat.net/css?family=Lato:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Roboto Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






  

<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">




<link href="/css/main.css?v=6.4.2" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.4.2">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.ico?v=6.4.2">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.4.2">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.2" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '6.4.2',
    sidebar: {"position":"left","display":"always","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="Syncing 是一个 VSCode 扩展，它能在多台设备之间同步你的所有 VSCode 配置（借助了你的 GitHub Gist）">
<meta name="keywords" content="开发环境,vscode,配置同步,synciong,插件">
<meta property="og:type" content="article">
<meta property="og:title" content="多台电脑同步VScode配置">
<meta property="og:url" content="https://blog.codenote.pro/multiple-computers-sync-vscode-configuration.html">
<meta property="og:site_name" content="九阳的笔记本">
<meta property="og:description" content="Syncing 是一个 VSCode 扩展，它能在多台设备之间同步你的所有 VSCode 配置（借助了你的 GitHub Gist）">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://vsmarketplacebadge.apphb.com/version/nonoroazoro.syncing.svg">
<meta property="og:image" content="https://vsmarketplacebadge.apphb.com/installs-short/nonoroazoro.syncing.svg">
<meta property="og:image" content="https://vsmarketplacebadge.apphb.com/rating/nonoroazoro.syncing.svg">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-29-43.gif">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-31-44.png">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-32-23.png">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-32-48.png">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-33-14.png">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-33-52.png">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-34-35.gif">
<meta property="og:image" content="http://qn.codenote.pro/2018-09-28-23-34-57.gif">
<meta property="og:updated_time" content="2018-11-01T16:22:00.482Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="多台电脑同步VScode配置">
<meta name="twitter:description" content="Syncing 是一个 VSCode 扩展，它能在多台设备之间同步你的所有 VSCode 配置（借助了你的 GitHub Gist）">
<meta name="twitter:image" content="https://vsmarketplacebadge.apphb.com/version/nonoroazoro.syncing.svg">



  <link rel="alternate" href="/atom.xml" title="九阳的笔记本" type="application/atom+xml">




  <link rel="canonical" href="https://blog.codenote.pro/multiple-computers-sync-vscode-configuration.html">



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>多台电脑同步VScode配置 | 九阳的笔记本</title>
  




<script async src="https://www.googletagmanager.com/gtag/js?id=UA-126970002-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-126970002-1');
</script>



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?07b2f6778635ec267ee2b4753e118da9";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
     
    
    
    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">九阳的笔记本</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-hexo">
    <a href="/categories/Hexo" rel="section">
      <i class="menu-item-icon fa fa-fw fa-header"></i> <br>Hexo</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-linux">
    <a href="/categories/Linux" rel="section">
      <i class="menu-item-icon fa fa-fw fa-linux"></i> <br>Linux</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-docker">
    <a href="/categories/docker" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>docker</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-learn">
    <a href="/categories/learn" rel="section">
      <i class="menu-item-icon fa fa-fw fa-leanpub"></i> <br>学习</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-top">
    <a href="/top/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-signal"></i> <br>阅读排行</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-sitemap">
    <a href="/sitemap.xml" rel="section">
      <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br>站点地图</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
        </li>
      
    </ul>
  

  
    

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://blog.codenote.pro/multiple-computers-sync-vscode-configuration.html">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="yszar">
      <meta itemprop="description" content="学无止境！">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="九阳的笔记本">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">多台电脑同步VScode配置
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-09-28 23:11:25" itemprop="dateCreated datePublished" datetime="2018-09-28T23:11:25+08:00">2018-09-28</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2018-11-02 00:22:00" itemprop="dateModified" datetime="2018-11-02T00:22:00+08:00">2018-11-02</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/编程写作/" itemprop="url" rel="index"><span itemprop="name">编程写作</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/multiple-computers-sync-vscode-configuration.html" class="leancloud_visitors" data-flag-title="多台电脑同步VScode配置">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数：</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          
              <div class="post-description">Syncing 是一个 VSCode 扩展，它能在多台设备之间同步你的所有 VSCode 配置（借助了你的 GitHub Gist）</div>
          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p class="description">Syncing 是一个 VSCode 扩展，它能在多台设备之间同步你的所有 VSCode 配置（借助了你的 GitHub Gist）</p>

<a id="more"></a>
<h1 id="Syncing"><a href="#Syncing" class="headerlink" title="Syncing"></a>Syncing</h1><p><a href="https://marketplace.visualstudio.com/items?itemName=nonoroazoro.syncing" rel="external nofollow noopener noreferrer" target="_blank"><img src="https://vsmarketplacebadge.apphb.com/version/nonoroazoro.syncing.svg" alt="Version"></a><br><a href="https://marketplace.visualstudio.com/items?itemName=nonoroazoro.syncing" rel="external nofollow noopener noreferrer" target="_blank"><img src="https://vsmarketplacebadge.apphb.com/installs-short/nonoroazoro.syncing.svg" alt="Installs"></a><br><a href="https://marketplace.visualstudio.com/items?itemName=nonoroazoro.syncing#review-details" rel="external nofollow noopener noreferrer" target="_blank"><img src="https://vsmarketplacebadge.apphb.com/rating/nonoroazoro.syncing.svg" alt="Ratings"></a></p>
<p><a href="README.md">English</a> | <a href="README.zh-CN.md">中文</a></p>
<p><strong>Syncing</strong> <em>(<a href="https://github.com/nonoroazoro/vscode-syncing" rel="external nofollow noopener noreferrer" target="_blank">源码</a>)</em> 是一个 VSCode 扩展，它能在<strong>多台设备之间同步你的所有 VSCode 配置</strong>（借助了你的 <a href="https://gist.github.com" rel="external nofollow noopener noreferrer" target="_blank">GitHub Gist</a>）。</p>
<p><a href="#快速开始">点击这里</a>快速开始配置吧，当然你也可以先看看<a href="#示例">示例</a>哦。</p>
<blockquote>
<p><em>我的目标是始终让它保持<strong>简单可靠</strong>，所以提需求别太过分啊 :)</em></p>
</blockquote>
<h2 id="重要变更"><a href="#重要变更" class="headerlink" title="重要变更"></a>重要变更</h2><ul>
<li><p>从 <strong><em>1.9.0</em></strong> 版本开始：</p>
<ol>
<li><p>支持 VSCode <a href="https://code.visualstudio.com/docs/editor/portable" rel="external nofollow noopener noreferrer" target="_blank">便携模式</a>。</p>
</li>
<li><p>将会从一个全新的 <code>CDN</code> 下载插件，以加速同步过程（对于那些不使用代理的用户来说效果应该更为显著）。</p>
</li>
</ol>
</li>
</ul>
<h2 id="功能"><a href="#功能" class="headerlink" title="功能"></a>功能</h2><p><em>Syncing</em> 可以在<code>本地和云端之间同步你的所有 VSCode 配置</code>，包括：</p>
<ol>
<li><p><strong>上传 VSCode 配置</strong>:</p>
<ul>
<li>包括你的<code>用户设置</code>，<code>快捷键</code>，<code>扩展</code>，<code>语言设置</code>以及所有<code>代码片段（Snippets）</code>；</li>
<li>因为 <code>Mac</code> 和<code>非 Mac</code> 设备的配置通常会有一些差异，所以<code>快捷键</code>将会按照操作系统的不同分别上传；</li>
<li>自动帮你创建新的 <code>Gist</code> 来保存 VSCode 配置，例如当你第一次使用这个扩展上传配置时；</li>
<li>为了加快同步速度，整个同步过程都是<code>增量</code>的；</li>
<li>你可以<code>排除某些 VSCode 配置项和扩展</code>，以防它们被上传，具体请参考<a href="#vscode-配置项">这里</a>。</li>
</ul>
</li>
<li><p><strong>下载 VSCode 配置</strong>:</p>
<ul>
<li>请注意，下载配置时会<strong>覆盖</strong>你的本地配置（以云端为准，精确同步）；</li>
<li>自动帮你<code>安装</code>、<code>升级</code>和<code>删除</code>扩展；</li>
<li>你可以从一个<code>公开的 Gist</code> 中下载配置。例如，下载你朋友分享的配置，只要问他要一个 <code>Gist ID</code> 就行了，具体请参考<a href="#快速开始">这里</a>；</li>
<li>你可以<code>排除某些 VSCode 配置项和扩展</code>，以防它们被下载，具体请参考<a href="#vscode-配置项">这里</a>。</li>
</ul>
</li>
</ol>
<p>另外，如果你访问 GitHub 有困难（万恶的墙），你可以<a href="#代理设置">配置一个代理</a>来加速同步。当然，同步时的<code>进度条</code>肯定有的咯！</p>
<h2 id="命令"><a href="#命令" class="headerlink" title="命令"></a>命令</h2><p>在 <code>VSCode 的命令面板</code>中，你可以输入 <code>upload</code>、<code>download</code>（或者 <code>syncing</code>）来快速搜索和执行 <code>Syncing</code> 的所有命令。</p>
<ol>
<li><p><strong><em><code>Syncing: Upload Settings</code></em></strong></p>
<blockquote>
<p>上传配置到 GitHub Gist。</p>
</blockquote>
</li>
<li><p><strong><em><code>Syncing: Download Settings</code></em></strong></p>
<blockquote>
<p>从 GitHub Gist 下载配置。</p>
</blockquote>
</li>
<li><p><strong><em><code>Syncing: Open Syncing Settings</code></em></strong></p>
<blockquote>
<p>设置 <code>GitHub Personal Access Token</code>、<code>Gist ID</code> 或<code>代理</code>。</p>
</blockquote>
</li>
</ol>
<h2 id="快捷键"><a href="#快捷键" class="headerlink" title="快捷键"></a>快捷键</h2><p><strong>默认情况下所有的快捷键都是关闭的</strong>，但是你可以很轻松的在 <code>VSCode 键盘快捷方式</code>中指定你想要的快捷键：</p>
<ol>
<li>如果你的 VSCode 版本<code>高于 1.11</code>（<strong><em>这是可视化的配置，强烈推荐</em></strong>）:</li>
</ol>
<p><img src="http://qn.codenote.pro/2018-09-28-23-29-43.gif" alt="2018-09-28-23-29-43.gif"></p>
<ol>
<li><p>如果你的 VSCode 版本<code>低于 1.11</code>，那就只能手动配置啦，参考一下：</p>
 <figure class="highlight json"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></div><div class="code"><pre><div class="line">&#123;</div><div class="line">    <span class="attr">"key"</span>: <span class="string">"alt+cmd+u"</span>,</div><div class="line">    <span class="attr">"command"</span>: <span class="string">"syncing.uploadSettings"</span></div><div class="line">&#125;,</div><div class="line">&#123;</div><div class="line">    <span class="attr">"key"</span>: <span class="string">"alt+cmd+d"</span>,</div><div class="line">    <span class="attr">"command"</span>: <span class="string">"syncing.downloadSettings"</span></div><div class="line">&#125;,</div><div class="line">&#123;</div><div class="line">    <span class="attr">"key"</span>: <span class="string">"alt+cmd+s"</span>,</div><div class="line">    <span class="attr">"command"</span>: <span class="string">"syncing.openSettings"</span></div><div class="line">&#125;</div></pre></div></div></figure>
</li>
</ol>
<h2 id="VSCode-配置项"><a href="#VSCode-配置项" class="headerlink" title="VSCode 配置项"></a>VSCode 配置项</h2><p>你可以在 <code>VSCode 用户设置</code>中找到以下 <code>Syncing</code> 配置项。</p>
<ol>
<li><p><strong><em><code>syncing.excludedExtensions</code></em></strong></p>
<p> 通过这个配置项，你可以<code>排除某些指定的 VSCode 扩展</code>，以防止它们被同步。当然其他扩展不受影响，依然会正常同步。</p>
<blockquote>
<p>配置规则可以参考 <a href="https://github.com/isaacs/minimatch" rel="external nofollow noopener noreferrer" target="_blank">Glob Patterns</a>。</p>
</blockquote>
<p> 举个栗子：</p>
 <figure class="highlight"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></div><div class="code"><pre><div class="line">"syncing.excludedExtensions" : [</div><div class="line">    "somepublisher.*",</div><div class="line">    <span class="string">"nonoroazoro.syncing"</span></div><div class="line">]</div></pre></div></div></figure>
</li>
</ol>
<pre><code>要注意的是，这里被排除的`扩展名称`其实是`扩展的 ID`（可在 VSCode 的`扩展`页中找到），如下图所示：

![2018-09-28-23-30-55.png](http://qn.codenote.pro/2018-09-28-23-30-55.png)

这样一来 `nonoroazoro.syncing`（也就是本扩展）以及所有属于 `somepublisher` 这个作者的扩展就不会再被同步啦。
</code></pre><ol start="2">
<li><p><strong><em><code>syncing.excludedSettings</code></em></strong></p>
<p> 通过这个配置项，你可以<code>排除某些指定的 VSCode 配置项</code>，以防止它们被同步。当然其他配置项不受影响，依然会正常同步。</p>
<blockquote>
<p>配置规则可以参考 <a href="https://github.com/isaacs/minimatch" rel="external nofollow noopener noreferrer" target="_blank">Glob Patterns</a>。</p>
</blockquote>
<p> 举个栗子：</p>
 <figure class="highlight"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></div><div class="code"><pre><div class="line">"syncing.excludedSettings" : [</div><div class="line">    "editor.*",</div><div class="line">    <span class="string">"workbench.colorTheme"</span></div><div class="line">]</div></pre></div></div></figure>
</li>
</ol>
<pre><code>这样一来你的 VSCode 主题（`workbench.colorTheme`）以及所有与编辑器（`editor`）相关的配置项就不会再被同步啦。
</code></pre><ol start="3">
<li><p><strong><em><code>syncing.extensions.autoUpdate</code></em></strong></p>
<p> 通过这个配置项，可以让 <code>Syncing</code> 在同步时自动升级你的 VSCode 扩展。</p>
<p> 这个功能是<code>默认开启</code>的，当然你也可以在 <code>VSCode 用户设置</code> 中关掉它。</p>
</li>
<li><p><strong><em><code>syncing.pokaYokeThreshold</code></em></strong></p>
<p> 同步配置时，<code>Syncing</code> 会检查你的本地和云端配置间的<code>差异数量</code>，如果超出这个阈值，就会显示一个确认对话框，以防错误的覆盖你的配置。</p>
<p> 这个配置项的默认值是 <code>10</code>，当然你也可以将其设置为一个<code>小于等于 0 的值</code>来关闭这个功能（不再检查和显示确认对话框）。</p>
<p> 举个栗子：</p>
 <figure class="highlight"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line">"syncing.pokaYokeThreshold" : 10</div></pre></div></div></figure>
</li>
</ol>
<pre><code>这样一来每次你同步时，`Syncing` 都会检查本地和云端的配置差异量，并决定是否需要向你显示确认对话框。
</code></pre><ol start="5">
<li><p><strong><em><code>syncing.separateKeybindings</code></em></strong></p>
<p> 通过这个配置项，可以决定是否让 <code>Syncing</code> 按照设备<code>操作系统</code>的不同来分开同步你的<code>快捷键</code>配置。</p>
<p> 因为 <code>VSCode</code> 在 <code>1.27</code> 版本开始提供了 <a href="https://code.visualstudio.com/updates/v1_27#_platform-specific-keybindings" rel="external nofollow noopener noreferrer" target="_blank">Platform Specific Keybindings</a> 功能，你现在可以禁用这个配置。注意：在禁用之前，请务必确保你已经手动合并了现有的<code>快捷键</code>配置。</p>
<p> 这个功能是<code>默认开启</code>的，当然你也可以在 <code>VSCode 用户设置</code> 中关掉它。</p>
</li>
</ol>
<h2 id="代理设置"><a href="#代理设置" class="headerlink" title="代理设置"></a>代理设置</h2><p>如果你访问 GitHub 有困难，比如在国内有万恶的墙，你可以配置一个代理来加速同步，具体步骤如下：</p>
<ol>
<li><p>在 <code>VSCode 的命令面板</code>中输入 <code>Syncing: Open Syncing Settings</code>（或者 <code>opensync</code>）来打开 <code>Syncing</code> 自己的配置文件（即 <code>syncing.json</code> 文件）；</p>
</li>
<li><p>修改 <code>http_proxy</code> 的值，例如：</p>
 <figure class="highlight"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line">"http_proxy": "http://127.0.0.1:1080"</div></pre></div></div></figure>
</li>
</ol>
<p>大功告成！另外，如果你不想在这里配置代理，那么 <code>Syncing</code> 也会尝试从系统环境中读取 <code>http_proxy</code> 和 <code>https_proxy</code> 作为代理设置。</p>
<blockquote>
<p>注意：不同于那些保存在 <a href="#vscode-配置项">VSCode 用户设置</a>中的 <code>Syncing</code> 配置项，这个独立的配置文件并<strong>不会被同步</strong>，因为里面保存了你的私人信息。</p>
</blockquote>
<h2 id="快速开始"><a href="#快速开始" class="headerlink" title="快速开始"></a>快速开始</h2><ol>
<li><p>创建你自己的 <code>GitHub Personal Access Token</code>（总共 3 步）：</p>
<ol>
<li><p>登录到你的 <strong><a href="https://github.com/settings/tokens" rel="external nofollow noopener noreferrer" target="_blank">GitHub Personal Access Tokens 页面</a></strong>，点击 <strong><code>Generate new token</code></strong>；</p>
<p> <img src="http://qn.codenote.pro/2018-09-28-23-31-44.png" alt="2018-09-28-23-31-44.png"></p>
</li>
<li><p>指定一个 <strong><code>name</code></strong>，然后勾选 <strong><code>gist</code></strong>，最后点击 <strong><code>Generate token</code></strong>；</p>
<p> <img src="http://qn.codenote.pro/2018-09-28-23-32-23.png" alt="2018-09-28-23-32-23.png"></p>
</li>
<li><p>点击 <strong><code>Copy</code></strong> 并且 <strong><code>备份</code></strong> 你的 Token。</p>
<p> <img src="http://qn.codenote.pro/2018-09-28-23-32-48.png" alt="2018-09-28-23-32-48.png"></p>
</li>
</ol>
</li>
<li><p>同步你的 VSCode 配置：</p>
<p> 在第一次使用时，<code>Syncing</code> 会向你询问一些必要的信息并保存下来以供后续使用，主要就是前面申请的 <code>GitHub Personal Access Token</code> 啦。</p>
<ol>
<li><p><strong>上传配置</strong></p>
<ol>
<li><p>在 <code>VSCode 的命令面板</code> 中输入 <code>upload</code>；</p>
<p> <img src="http://qn.codenote.pro/2018-09-28-23-33-14.png" alt="2018-09-28-23-33-14.png"></p>
</li>
<li><p>填写刚才申请的 <code>GitHub Personal Access Token</code>；</p>
</li>
<li><p>在下拉框中选择或者手动输入一个 <code>Gist ID</code>；</p>
<blockquote>
<p>你可以留空，那样的话 <code>Syncing</code> 会自动帮你创建一个新的 <code>Gist</code>。</p>
</blockquote>
</li>
<li><p>完成！</p>
</li>
<li><p><em>在上传完成后，你可以在 <a href="https://gist.github.com" rel="external nofollow noopener noreferrer" target="_blank">GitHub Gist</a> 中找到对应的 <code>Gist</code> 和 <code>Gist ID</code>。当然你也可以通过 <code>Edit</code> 和 <code>make it public</code> 操作将你的配置共享给其他人。</em></p>
</li>
</ol>
</li>
<li><p><strong>下载配置</strong></p>
<ol>
<li><p>在 <code>VSCode 的命令面板</code> 中输入 <code>download</code>；</p>
<p> <img src="http://qn.codenote.pro/2018-09-28-23-33-52.png" alt="2018-09-28-23-33-52.png"></p>
</li>
<li><p>填写你的 <code>GitHub Personal Access Token</code>；</p>
<blockquote>
<p>你可以留空，那样的话就能从一个<code>公开的 Gist</code>（比如你朋友共享给你的 <code>Gist</code>）来下载配置了。</p>
</blockquote>
</li>
<li><p>在下拉框中选择或者手动输入一个 <code>Gist ID</code>（当然这里也可以输入一个<code>公开的 Gist ID</code>）。</p>
</li>
<li><p>完成！</p>
</li>
</ol>
</li>
</ol>
</li>
</ol>
<h2 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h2><ol>
<li><p>上传配置：</p>
<p> <img src="http://qn.codenote.pro/2018-09-28-23-34-35.gif" alt="2018-09-28-23-34-35.gif"></p>
</li>
<li><p>下载配置：</p>
<p> <img src="http://qn.codenote.pro/2018-09-28-23-34-57.gif" alt="2018-09-28-23-34-57.gif"></p>
</li>
</ol>
<h1 id="我的设置-github-token"><a href="#我的设置-github-token" class="headerlink" title="我的设置(github token)"></a>我的设置(github token)</h1><p>bf1d54ecf281df70459235324737e84c5db3294b</p>

      
    </div>

    
      


    

    
    
    
    
    <div>
        
        <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
        
    </div>
    
    <div>
          
            
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <p><span>本文标题:</span><a href="/multiple-computers-sync-vscode-configuration.html">多台电脑同步VScode配置</a></p>
  <p><span>文章作者:</span><a href="/" title="访问 yszar 的个人博客">yszar</a></p>
  <p><span>发布时间:</span>2018年09月28日 - 23:09</p>
  <p><span>最后更新:</span>2018年11月02日 - 00:11</p>
  <p><span>原始链接:</span><a href="/multiple-computers-sync-vscode-configuration.html" title="多台电脑同步VScode配置">https://blog.codenote.pro/multiple-computers-sync-vscode-configuration.html</a>
    <span class="copy-path" title="点击复制文章链接"><i class="fas fa-copy" data-clipboard-text="https://blog.codenote.pro/multiple-computers-sync-vscode-configuration.html" aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="external nofollow noopener noreferrer" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
      $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({   
          title: "",   
          text: '复制成功',
          icon: "success", 
          showConfirmButton: true
          });
        });
    });  
</script>


          
    </div>

    
      <div>
        <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/uploads/wechat-qcode.jpg" alt="yszar wechat" style="width: 200px; max-width: 100%;">
    <div>欢迎您扫一扫上面的微信公众号，订阅我的博客！</div>
</div>

      </div>
    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/uploads/wxfk.png" alt="yszar 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/uploads/zfbfk.png" alt="yszar 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/插件/" rel="tag"><i class="fa fa-tag"></i> 插件</a>
          
            <a href="/tags/开发环境/" rel="tag"><i class="fa fa-tag"></i> 开发环境</a>
          
            <a href="/tags/vscode/" rel="tag"><i class="fa fa-tag"></i> vscode</a>
          
            <a href="/tags/配置同步/" rel="tag"><i class="fa fa-tag"></i> 配置同步</a>
          
            <a href="/tags/synciong/" rel="tag"><i class="fa fa-tag"></i> synciong</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        
          <div class="wp_rating">
          <div style="color: rgba(0, 0, 0, 0.75); font-size:13px; letter-spacing:3px">(&gt;看完记得五星好评哦亲&lt;)</div>
            <div id="wpac-rating"></div>
          </div>
        

        

        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
            
              
              <a href="/next-theme-personalization-using-fontawesome5.html" rel="prev" title="NexT主题个性化-使用FontAwesome5">
                
                <i class="fa fa-chevron-left"></i> NexT主题个性化-使用FontAwesome5
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
            
              
              <a href="/using-ssr-on-ubunt.html" rel="next" title="Ubunt上使用SSR">
                
                Ubunt上使用SSR <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  
       <div id="gitalk-container"></div>
       <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">yszar</p>
              <p class="site-description motion-element" itemprop="description">学无止境！</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">21</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">5</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">42</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/yszar" target="_blank" title="GitHub" rel="external nofollow noopener noreferrer"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:yszar@vip.qq.com" target="_blank" title="E-Mail" rel="external nofollow noopener noreferrer"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  
                </span>
              
            </div>
          

          
          
            <div class="cc-license motion-element" itemprop="license">
              <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank" rel="external nofollow noopener noreferrer">
                <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons">
              </a>
            </div>
          

          
          

          
            
          
          
        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Syncing"><span class="nav-number">1.</span> <span class="nav-text">Syncing</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#重要变更"><span class="nav-number">1.1.</span> <span class="nav-text">重要变更</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#功能"><span class="nav-number">1.2.</span> <span class="nav-text">功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令"><span class="nav-number">1.3.</span> <span class="nav-text">命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#快捷键"><span class="nav-number">1.4.</span> <span class="nav-text">快捷键</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#VSCode-配置项"><span class="nav-number">1.5.</span> <span class="nav-text">VSCode 配置项</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代理设置"><span class="nav-number">1.6.</span> <span class="nav-text">代理设置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#快速开始"><span class="nav-number">1.7.</span> <span class="nav-text">快速开始</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#示例"><span class="nav-number">1.8.</span> <span class="nav-text">示例</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#我的设置-github-token"><span class="nav-number">2.</span> <span class="nav-text">我的设置(github token)</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  
  <span class="with-love" id="heart">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yszar</span>

  

  
</div>


  










<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共38.6k字</span>
</div>
<div class="post-count">
	<a href="http://www.miitbeian.gov.cn/" rel="external nofollow noopener noreferrer" target="_blank">陇ICP备15003024号</a>
</div>


<div class="weixin-box">
  <div class="weixin-menu">
    <div class="weixin-hover">
      <div class="weixin-description">微信扫一扫，订阅本博客</div>
    </div>
  </div>
</div>
        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>












  















  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/jquery@2.1.3/dist/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.2"></script>



  



  










   
     
       <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>

      <script src="/js/src/md5.min.js"></script>

       <script type="text/javascript">
         const gitalk = new Gitalk({
           clientID: '54f26977793794b45255',
           clientSecret: '568cccb3bdde42eca6c05ab0680b4617bbb58c4f',
           repo: 'yszar.github.io',
           owner: 'yszar',
           admin: 'yszar'.split(','),
           id: md5(location.pathname),
           pagerDirection: 'first',
           // facebook-like distraction free mode
           distractionFreeMode: false
         })
         gitalk.render('gitalk-container')
       </script>
     
   
 
  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  
  <script>
    
    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();

      Counter('get', '/classes/Counter', { where: JSON.stringify({ url }) })
        .done(function ({ results }) {
          if (results.length > 0) {
            var counter = results[0];
            
              var $element = $(document.getElementById(url));
              $element.find('.leancloud-visitors-count').text(counter.time + 1);
            
            Counter('put', `/classes/Counter/${counter.objectId}`, JSON.stringify({ time: { "__op":"Increment", "amount":1 } }))
            
            .fail(function ({ responseJSON }) {
                console.log('Failed to save Visitor num, with error message: ' + responseJSON.error);
            })
          } else {
            
              Counter('post', '/classes/Counter', JSON.stringify({ title: title, url: url, time: 1}))
                .done(function () {
                  var $element = $(document.getElementById(url));
                  $element.find('.leancloud-visitors-count').text(1);
                })
                .fail(function () {
                  console.log('Failed to create');
                });
            
          }
        })
      .fail(function ({ responseJSON }) {
        console.log('LeanCloud Counter Error:' + responseJSON.code + " " + responseJSON.error);
      });
    }
    

    $(function() {
      $.get('https://app-router.leancloud.cn/2/route?appId=' + "iUS887d8BnkY3Gqc9FJX70fE-gzGzoHsz")
        .done(function ({ api_server }) {
          var Counter = function (method, url, data) {
            return $.ajax({
              method: method,
              url: `https://${api_server}/1.1${url}`,
              headers: {
                'X-LC-Id': "iUS887d8BnkY3Gqc9FJX70fE-gzGzoHsz",
                'X-LC-Key': "ekF4kKyQDgrDkIBadj3IDrVA",
                'Content-Type': 'application/json',
              },
              data: data,
            });
          };
          
          addCount(Counter);
          
        })
    });
  </script>



  

  

  

  
  
  <script type="text/javascript">
  wpac_init = window.wpac_init || [];
  wpac_init.push({widget: 'Rating', id: 14244,
    el: 'wpac-rating',
    color: 'fc6423'
  });
  (function() {
    if ('WIDGETPACK_LOADED' in window) return;
    WIDGETPACK_LOADED = true;
    var mc = document.createElement('script');
    mc.type = 'text/javascript';
    mc.async = true;
    mc.src = '//embed.widgetpack.com/widget.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
  })();
  </script>


  

  

  

  

  
  <style>
    .copy-btn {
      display: inline-block;
      padding: 6px 12px;
      font-size: 13px;
      font-weight: 700;
      line-height: 20px;
      color: #333;
      white-space: nowrap;
      vertical-align: middle;
      cursor: pointer;
      background-color: #eee;
      background-image: linear-gradient(#fcfcfc, #eee);
      border: 1px solid #d5d5d5;
      border-radius: 3px;
      user-select: none;
      outline: 0;
    }

    .highlight-wrap .copy-btn {
      transition: opacity .3s ease-in-out;
      opacity: 0;
      padding: 2px 6px;
      position: absolute;
      right: 4px;
      top: 8px;
    }

    .highlight-wrap:hover .copy-btn,
    .highlight-wrap .copy-btn:focus {
      opacity: 1
    }

    .highlight-wrap {
      position: relative;
    }
  </style>
  <script>
    $('.highlight').each(function (i, e) {
      var $wrap = $('<div>').addClass('highlight-wrap')
      $(e).after($wrap)
      $wrap.append($('<button>').addClass('copy-btn').append('复制').on('click', function (e) {
        var code = $(this).parent().find('.code').find('.line').map(function (i, e) {
          return $(e).text()
        }).toArray().join('\n')
        var ta = document.createElement('textarea')
        document.body.appendChild(ta)
        ta.style.position = 'absolute'
        ta.style.top = '0px'
        ta.style.left = '0px'
        ta.value = code
        ta.select()
        ta.focus()
        var result = document.execCommand('copy')
        document.body.removeChild(ta)
        
          if(result)$(this).text('复制成功')
          else $(this).text('复制失败')
        
        $(this).blur()
      })).on('mouseleave', function (e) {
        var $b = $(this).find('.copy-btn')
        setTimeout(function () {
          $b.text('复制')
        }, 300)
      }).append(e)
    })
  </script>


  
</body>
</html>
